import java.util.Scanner;

public class RoomManagement {
    public static void main(String[] args) { //静态方法只能调用静态方法
        String  select ;
        String command ;
        String []str_Arrays ;
        String [][]rooms = new String[][]{
                {"1101" , null},
                {"1102" , null},
                {"1103" , null}
        };
        Scanner scanner = new Scanner( System.in ) ;
        while (true){                                                  // 命令匹配函数
            command = scanner.nextLine() ;
            str_Arrays = command.split(" ") ;
            select = str_Arrays[0] ;
            switch ( select ){
                case "in" : checkIn( str_Arrays , rooms ) ; break;
                case "out" : checkOut( str_Arrays , rooms ) ; break;
                case "search" : search(  rooms ) ; break;
                case "quit" : return;
                default:
                   System.out.println("错误命令") ;
            }
        }

    }
    public  static void checkIn( String []command ,String [][]rooms) {   //入住函数
        for (int i = 0; i < rooms.length; i++) {

                if ( command[1].equals( rooms[i][0] ) ){

                    if ( rooms [i][1] == null) {
                        rooms[i][1] = command[2];
                        System.out.println( "恭喜你," + command[2] + "成功入住" + rooms [i][0] + "号房间！");
                        return ;
                    }else{
                        System.out.println( "该房已满人！" );
                    }
                    return ;
                }
        }
        System.out.println( "没有这个房间" );
        return ;
    }
    public  static void checkOut( String []command ,String [][]rooms ){ //退房函数
        for (int i = 0; i < rooms.length; i++) {
            if (  command[1].equals( rooms[i][0] ) ){
                if ( rooms [i][1] != null) {
                    rooms[i][1] = null ;
                    System.out.println( "退房成功！" );
                    return ;
                }else{
                    System.out.println( "该房为空房！" );
                }
                return ;
            }
        }
        System.out.println( "没有这个房间" );
        return ;
    }
    public  static void search( String [][]rooms ){                 //打印所有房间信息函数
        for (int i = 0; i < rooms.length; i++) {
            for (int j = 0; j < rooms[i].length; j++) {
                System.out.print( "\t" + rooms[i][j]);
            }
            System.out.println();
        }
    }

}
